<?php
namespace common\models\order;

use Yii;
use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;
use common\enums\StatusEnum;
use common\helpers\RegularHelper;

/**
 * This is the model class for table "{{%order_pay}}".
 *
 */
class OrderPay extends ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%order_pay}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['order_id','goods_id','goods_price','goods_num','goods_pay_price','store_id','buyer_id'], 'required'],
            [['order_id','goods_id','goods_num','store_id','buyer_id','promotions_id','commis_rate'], 'integer'],
            [['goods_price','goods_pay_price'], 'number'],
            [['goods_name'], 'string', 'max' => 50],
            [['goods_image'],'string','max'=>100],
            ['goods_type','string']
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'pay_id' => 'ID',
            'pay_sn' => '支付单号',
            'buyer_id'=>'买家ID',
            'api_pay_state' => '支付状态',//0默认未支付1已支付(只有第三方支付接口通知到时才会更改此状态)

        ];
    }

    /**
     * 场景
     *
     * @return array
     */
    public function scenarios()
    {
        return [
//            'backendCreate' => ['goods_name', 'goods_code','goods_bar','goods_unit','gc_id','member_id','store_id'],
            'default' => array_keys($this->attributeLabels()),
        ];
    }


    /**
     * @return array
     */
//    public function behaviors()
//    {
//        return [
//            [
//                'class' => TimestampBehavior::class,
//                'attributes' => [
//                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
//                ],
//            ],
//        ];
//    }
}
